<extend name="Layout/application"/>

<block name="content">
    <div class="row">
        <div class="col-md-12">

            <div class="row">
                <div class="col-md-8">
                    <div class="page-header">
                        <h1>栏目管理</h1>
                    </div>
                </div>
            </div>

            <div class="row">
                <div class="col-md-10">
                    <div class="panel panel-default">
                        <div class="panel-heading">栏目管理</div>

                        <div class="panel-body">
                            <table class="table">
                                <thead>
                                <tr>
                                    <th class="col-md-1">排序</th>
                                    <th>名称</th>
                                    <th>栏目文章</th>
                                    <th>操作</th>
                                </tr>
                                </thead>
                                <form action="" id="form" method="post">
                                    <tbody>
                                        <volist name="categories" id="category">
                                        <tr>
                                            <input type="hidden" name="id[]" value="{{$category.id}}">
                                            <td class="col-md-1"><input type="text" name="sort_order[]" value="{{$category.sort_order}}" style="width: 40%"></td>
                                            <td>{{$category.name}}</td>
                                            <td>　</td>
                                            <td>
                                                <a href="{{:U('edit_category',array('id'=>$category['id']))}}" class="edit">
                                                    <span class="glyphicon glyphicon-pencil"></span>
                                                </a>
                                                <a href="{{:U('destroy_category',array('id'=>$category['id']))}}">
                                                    <span class="glyphicon glyphicon-trash"></span>
                                                </a>
                                            </td>
                                        </tr>
                                            <volist name="category.children" id="c">

                                                <tr>
                                                    <input type="hidden" name="id[]" value="{{$c.id}}">
                                                    <td class="col-md-1"><input type="text" name="sort_order[]" value="{{$c.sort_order}}" style="width: 40%"></td>
                                                    <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{{$c.name}}</td>
                                                    <td><a href="{{:U('CategoryArticle/article_list',array('id'=>$c['id']))}}">查看栏目文章</a></td>
                                                    <td>
                                                        <a href="{{:U('edit_category',array('id'=>$c['id']))}}" class="edit">
                                                            <span class="glyphicon glyphicon-pencil"></span>
                                                        </a>
                                                        <a href="{{:U('destroy_category',array('id'=>$c['id']))}}">
                                                            <span class="glyphicon glyphicon-trash"></span>
                                                        </a>
                                                    </td>
                                                </tr>
                                            </volist>
                                        </volist>
                                    </tbody>
                                </form>
                            </table>
                        </div>
                    </div>
                </div>


                <div class="col-md-2">
                    <div class="list-group">
                        <a href="{{:U('create_category')}}" class="list-group-item list-group-item-info sort_category">
                            <span class="glyphicon glyphicon-plus" aria-hidden="true"></span> 新增 (add)
                        </a>

                        <a href="javascript: void 0;" class="list-group-item list-group-item-info sort_category" id="sort_order">
                            <span class="glyphicon glyphicon-refresh" aria-hidden="true"></span> 排序 (sort)
                        </a>

                    </div>
                </div>
            </div>
        </div>
    </div>
</block>
<block name="js">
    <script>
        $(function () {
            $('#sort_order').click(function () {
                $('#form').attr('action',"{{:U('sort_order')}}").submit();

            })

        })
    </script>
</block>